import { TTaskName } from "../../../Message/Db/Tables/TTaskName";
import { TaskCode } from "../rules/TaskCode";
import { Language } from "../../../extend/language/Language";
import { TTaskConfig } from "../../../Message/Db/Tables/TTaskConfig";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class TaskConfig
    
    export  class TaskConfig
    {
        constructor()
        {
            
            this.initTaskNames();
            return;
        }

        public getTaskName(arg1: int): string
        {
            if (this._taskNames.hasOwnProperty(arg1.toString())) 
            {
                return (this._taskNames[arg1.toString()] as TTaskName).taskName;
            }
            if (arg1 == TaskCode.GuildTask) 
            {
                return Language.getString(20236);
            }
            if (arg1 == TaskCode.CycleTask) 
            {
                return Language.getString(20237);
            }
            if (arg1 == TaskCode.SchoolTask) 
            {
                return Language.getString(20180);
            }
            if (arg1 == TaskCode.EvilReliseTask) 
            {
                return Language.getString(20728);
            }
            if (arg1 == TaskCode.EvilGetTask) 
            {
                return Language.getString(20729);
            }
            return "";
        }

        public getTaskConfigByCode(arg1: int): TTaskConfig
        {
            return this._taskConfig[arg1];
        }

        /* internal  */initTaskNames(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            this._taskNames = new Map<any, any> /* flash.utils.Dictionary */();
            var loc1=ConfigManager.instance.getJSONByFileName("t_task_name.json");
            var loc6=0;
            var loc7=loc1;
            for(loc2 of loc7) 
            {
                loc3 = new TTaskName();
                this.copyValue(loc3, loc2);
                loc4 = loc3.taskCode.toString();
                this._taskNames[loc4] = loc3;
            }
            this._taskConfig = new Map<any, any> /* flash.utils.Dictionary */();
            loc1 = ConfigManager.instance.getJSONByFileName("t_task_config.json");
            loc6 = 0;
            loc7 = loc1;
            for(loc2 of loc7) 
            {
                loc5 = new TTaskConfig();
                this.copyValue(loc5, loc2);
                this._taskConfig[loc5.code] = loc5;
            }
            return;
        }

        /* internal  */copyValue(arg1: Object, arg2: Object): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=arg2;
            for (loc1 in loc3) 
            {
                arg1[loc1] = arg2[loc1];
            }
            return;
        }

        public static get instance(): TaskConfig
        {
            if (TaskConfig._instance == null) 
            {
                TaskConfig._instance = new TaskConfig();
            }
            return TaskConfig._instance;
        }

        /* internal */ /* var */_taskNames: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_taskConfig: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: TaskConfig;
    }
